package top.zhangjianyong.tools.controller;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import top.zhangjianyong.tools.service.api.CanteenService;
import top.zhangjianyong.tools.timer.CanteenTimer;
import top.zhangjianyong.tools.user.VerifyUser;
import top.zhangjianyong.tools.utils.ApiResponse;

import java.util.Map;

/**
 * @author ： zhangjianyong
 * @date ： 2022/9/27 8:43 AM
 */
@VerifyUser(login = false)
@Slf4j
@RestController
@RequestMapping("/canteen")
public class CanteenController {
    @Autowired
    private CanteenService canteenService;

    @PostMapping("/start")
    public ApiResponse startTimer(@RequestBody Map<String, String> map) {
        log.info("[点餐参数] {}", JSONObject.toJSONString(map));
        String password = map.get("password");
        if (!password.equals("3611")) {
            return ApiResponse.fail("密码错误");
        }
        canteenService.startTimer();
        return ApiResponse.success();

    }
}
